<?php
// @filename   page_helper.php
// @version    1.0
// @author     洪明伟@shstorm
// @contact    hongmingwei@shstorm.com
// @update     2009-10-16
// @comment    Some Comments

if(!function_exists('log_common')) {
    function log_common($type='common',$file,$method,$txt='',$params=array()) {
        $CI = & get_instance();
        $dir = $CI->config->item('log_uri');
        $dir .= date('Y-m-d').'/';
        if(!file_exists($dir)){
        	mkdir($dir,0777);
        }
        $logfile = $dir.$type.'.log';
        $fp = fopen($logfile,"a");	
		flock($fp, LOCK_EX) ;
		$date = date('Y-m-d H:i:s');
		$content = $date.' file=>'.$file.', method=>'.$method.', desc=>'.$txt;
		if (is_array($params) && count($params)){
			$content .= ', params(';
			foreach($params as $key=>$val){
				$content .= $key.'=>'.$val.',';
			}
			$content .= ')';
		}
		$content .= "\n";
		fwrite($fp,$content);
		flock($fp, LOCK_UN); 
		fclose($fp);
    }
}

?>